home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / info-service / gopher / Rice_CMS / gopher24 / gopsrvgl.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1993-01-25  |  2.3 KB  |  76 lines

  1. /*
  2.  *        Name: GOPSRVGL REXX
  3.  *              read and process a GOPHER (link) file for GOPHERD
  4.  *      Author: Rick Troth, Rice University, Information Systems
  5.  *        Date: 1993-Jan-15
  6.  */
  7.  
  8. /*
  9.  *      Copyright 1993 Richard M. Troth.   This software was developed
  10.  *      with resources provided by Rice University and is intended
  11.  *      to serve Rice's user community.   Rice has benefitted greatly
  12.  *      from the free distribution of software,  therefore distribution
  13.  *      of unmodified copies of this material is not restricted.
  14.  *      You may change your own copy as needed.   Neither Rice
  15.  *      University nor any of its employees or students shall be held
  16.  *      liable for damages resulting from the use of this software.
  17.  */
  18.  
  19. Address "COMMAND" 'GLOBALV SELECT GOPHERD GET HOST PORT'
  20. localhost = host;   localport = port
  21. host = "";  port = "";  path = "";  name = "";  type = ""
  22.  
  23. Do Forever
  24.  
  25.     'PEEKTO RECORD'
  26.     If rc ^= 0 Then Leave
  27.  
  28.     If Left(record,1) = '*' Then Call WRITELINK
  29.     If Left(record,1) = '#' Then Call WRITELINK
  30.     If rc ^= 0 Then Leave
  31.  
  32.     Parse Var record var '=' val
  33.     Upper var; var = Strip(var)
  34.     Select  /*  var  */
  35.         When var = "TYPE" Then type = Strip(val)
  36.         When var = "NAME" Then name = val
  37.         When var = "PATH" Then path = val
  38.         When var = "HOST" Then host = Strip(val)
  39.         When var = "PORT" Then port = Strip(val)
  40.         Otherwise nop   /*  ignore invalid lines  */
  41.         End  /*  Select  var  */
  42.  
  43.     'READTO'
  44.     If rc ^= 0 Then Leave
  45.  
  46.     End  /*  Do  Forever  */
  47.  
  48. If rc = 12 Then Call WRITELINK
  49.  
  50. Exit rc * (rc ^= 12)
  51.  
  52.  
  53.  
  54. /* ----------------------------------------------------------- WRITELINK
  55.  *  Looks like a break.  Iff we have everthing,
  56.  *  then write this link and reset the variables to empty strings.
  57.  */
  58. WRITELINK:
  59. If  name = "" | type = "" Then  Return
  60. If  host = ""   Then host = localhost
  61. If  host = "+"  Then host = localhost
  62. If  type = "FILE"       Then type = '0'
  63. If  type = "DIRECTORY"  Then type = '1'
  64. If  port = "" Then
  65. Select  /*  type  */
  66.     When  type = '2'  Then port = '105'
  67.     When  type = '8'  Then port = '23'
  68.     When  type = 'T'  Then port = '23'
  69.     Otherwise port = '70'
  70.     End  /*  Select  type  */
  71. 'OUTPUT' type || name || '05'x || path || '05'x ,
  72.               || host || '05'x || port
  73. host = "";  port = "";  path = "";  name = "";  type = ""
  74. Return
  75.  
  76.